#ifndef NETWORK_H
#define NETWORK_H

#include "Network.h"
#include "CrossRoad.h"
#include "Lane.h"
#include "InOut.h"
#include "Vehicle.h"
#include "TraficLight.h"
#include "GiveWay.h"
#include "Stop.h"
#include "Coord.h"
#include "Util.h"
#include <math.h>
#include "ModelManager.h"

using namespace std;

#include <iostream>
#include <fstream>
#include <string>
#include <time.h>
#include <windows.h>

struct CUSTOMVERTEX2 {FLOAT X, Y, Z, XN, YN, ZN; /*INT R G B;*/ DWORD COLOR;};
#define CUSTOMFVF2 (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE)

class Network {
    private :
        char* fileName;
		ModelManager mm;

		float generationRadius;
		float destructionRadius;
		static int vehicleCount;

		int getNewVehicleId();

		bool circlesVisible;
		bool circlesFixed;
		float xFixed, yFixed;

    public:
        vector<CrossRoad*> listCrossRoad;
        vector<Lane*> listLane;
        vector<RoadSign*> listRoadSign;

        Network();
        Network(char*);

        void addLane(Lane* l);
        void eraseLane(Lane* l);

		void setModelManager(ModelManager);

        CrossRoad* getCrossRoad(int id);

		RoadSign* getRoadSign(int id);

		Lane* getLane(int id);

        void addCrossRoad(CrossRoad* c);
        void eraseCrossRoad(CrossRoad* c);

        void addRoadSign(RoadSign* rs);
        void eraseRoadSign(RoadSign* rs);

        int getId() const;
        void setId(int Id);

        void toString();
		void import();
		void update(float,float);
		float distance(float,float,float,float);
		void directionChoice(Lane*, Vehicle*);
		void moveVehicle(Vehicle*, float, float, float, float, char);
		void switchVehicle_CrossRoadToLane(CrossRoad* cCur,Vehicle* vCur,Lane*);
		void switchVehicle_LaneToCrossRoad(Lane* lCur,Vehicle* vCur,CrossRoad*);
		void actionToRoadSign(RoadSign*,CrossRoad*,Vehicle*);
		void initTraficLight();
		void synchroTraficLight();
		void roadSignOrientation();
		float getAngle(float,float,float,float,float,float);

		float getGenerationRadius();
		void setGenerationRadius(float);
		float getDestructionRadius();
		void setDestructionRadius(float);
		void generateVehicles(float,float);
		void deleteVehicles(float,float);

		void render();
		void renderCircle(float,float);

		void switchCirclesVisible();
		void switchCirclesFixed();
};

#endif


